import { defineStore } from "pinia";
import { ref } from "vue";
import { UserInfo } from "./interface/userInterface";
export const useUserStore = defineStore(
	"user",
	() => {
		const token = ref("");
		const userInfo = ref<UserInfo>({
			id: "",
			name: "",
			avatar: "",
			phone: "",
			email: "",
			status: "",
		});
		const isLogin = ref(false);

		const checkLogin = () => {
			if (token.value) {
			} else {
			}
		};
		return {
			token,
			userInfo,
			isLogin,
			checkLogin,
		};
	},
	{
		unistorage: {
			key: "user", // 在缓存里面 key 值
			storage: localStorage,
			paths: ["token", "userInfo", "isLogin"], // 需要缓存哪些变量
		},
	}
);
